<?php

class EPMenuItem extends CComponent{

	private $_menuList=NULL;
	private $_subMenu=NULL;
	private $_attributes=array();

	private $_linkCss=array();
	private $_itemCss=array();

	public $itemId;
	public $label;
	public $url;
	public $visible=true;
	public $menuOrderId=0;
	public $menuDepth=0;
	public $cssPrefix='';



	public $linkHtmlOptions=array();
	public $listItemHtmlOptions=array();



	function __construct(&$menuList=NULL){
		if($menuList!==NULL){
			$this->_menuList=&$menuList;
			$this->cssPrefix=$menuList->cssPrefix;
		}
	}

	function setAttribute($name,$value){
		$this->_attributes[$name]=$value;
	}

	function getAttribute($name){
		if(isset($this->_attributes[$name])){
			return $this->_attributes[$name];
		}
		return NULL;
	}

	/*	function addSubMenu(&$menuitem){
		$this->subMenuItems[]=&$menuitem;
		if(empty($menuitem->parentItem)){
		$menuitem->parentItem=&$this;
		}
		}*/
	function hasSubMenu(){
		return !empty($this->_subMenu);
	}

	function getSubMenu(){
		if($this->_subMenu===NULL){
			$this->_subMenu=new EPMenuList($this);

			$this->_subMenu->menuDepth=$this->menuDepth+1;
		}
		return $this->_subMenu;
	}

	function addLinkCss($css){
		$css=$this->cssPrefix.$css;
		if(!empty($css)&&!in_array($css,$this->_linkCss)){
			$this->_linkCss[]=$css;
		}
	}
	function getLinkCss(){
		return $this->_linkCss;
	}


	function addItemCss($css){
		$css=$this->cssPrefix.$css;
		if(!empty($css)&&!in_array($css,$this->_itemCss)){
			$this->_itemCss[]=$css;
		}
	}

	function getItemCss(){
		return $this->_itemCss;
	}

	function getMenuList(){
		return $this->_menuList;
	}

}